﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Jogo_Grupo2.Cenas;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace Jogo_Grupo2.Telas
{
    class Menu:CenaBase
    {
        public SpriteFont sfont;
        Color CorSelecao = Color.Red;
        public int selecao = 0;
        KeyboardState lastk, currentk;
        

        public override void start()
        {
            Console.WriteLine("Menu");
            sfont = Game1.instancia.Content.Load<SpriteFont>("spritefonte");
            //GerenciadorDeCenas.setarcena(new Level());


        }
        public override void update(GameTime gameTime)
        {
            lastk = currentk;
            currentk = Keyboard.GetState();

            if (currentk.IsKeyDown(Keys.Down) && lastk != currentk && selecao < 1)
            {
                selecao++;
            }
            else if (currentk.IsKeyDown(Keys.Up) && lastk != currentk && selecao > 0)
            {
                selecao--;
            }
            else if ((selecao==0)&&(currentk.IsKeyDown(Keys.Enter)))
            {
                GerenciadorDeCenas.setarcena(new Level());
            }
            else if ((selecao == 1) && (currentk.IsKeyDown(Keys.Enter)))
            {
                Game1.instancia.Exit();
            }


        }
        public override void draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(Game1.instancia.Content.Load<Texture2D>("MenuBackground"), new Rectangle(0, 0, 1000, 500), Color.White);

            Game1.instancia.GraphicsDevice.Clear(Color.Black);
            if (selecao == 0)
            {
                spriteBatch.DrawString(sfont, "JOGAR", new Vector2(300, 150), CorSelecao);
                spriteBatch.DrawString(sfont, "SAIR", new Vector2(308, 300), Color.DarkGray);
                

            }
            else if (selecao == 1)
            {
                spriteBatch.DrawString(sfont, "JOGAR", new Vector2(300, 150), Color.DarkGray);
                spriteBatch.DrawString(sfont, "SAIR", new Vector2(308, 300), CorSelecao);
                
            }
            
        }
        public override void terminate()
        {
        }

    }
}
